<?php

namespace App\Console;

use DB;
use Illuminate\Console\Command;

class AdminDataInitCommand extends Command
{
    protected $model;
    protected $dataFilePath;

    public function handle()
    {
        DB::transaction(function () {
            $this->model::truncate();
            $this->model::insert($this->data());
        });
    }

    protected function data()
    {
        return require $this->dataFilePath;
    }
}
